<?php
/**
 * Created by PhpStorm.
 * User: sosyuki
 * Date: 2018/5/30
 * Time: 11:23
 */

namespace Drupal\distribution\Entity;


use Entity;

class DistributionApply extends Entity {

  public $id;

  public $vid;

  public $uid;

  public $op_uid;

  public $log = "";

  public $status = 0;


  public $name;

  public $tel;

  public $birthday;


  public $created;

  public $changed;

  public $is_new_revision;

  public $month;

  public $day;

  function __construct($values = []) {
    $this->is_new_revision = TRUE;
    list($month, $day) = explode('.', $this->birthday);
    $this->month = $month - 1;
    $this->day = $day - 1;
    parent::__construct($values, 'distribution_apply');
  }

  public function save() {
    $this->changed = REQUEST_TIME;

    if (empty($this->op_uid)) {
      global $user;
      $this->op_uid = $user->uid;
    }

    if (empty($this->created)) {
      $this->created = REQUEST_TIME;
    }

    parent::save();
  }


}
